package com.woniuxy.controller;

import com.woniuxy.entity.RbacRole;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacRoleService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/rbacRole")
public class RbacRoleController {
    @Autowired
    RbacRoleService rbacRoleService;
    //    @RequiresPermissions(logical= Logical.OR,value = {"role:list"})
    @GetMapping("/")
    public ResponseEntity findAll(){
        return rbacRoleService.findAll();
    }
    @GetMapping("/{id}")
    public ResponseEntity findOne(@PathVariable("id") int id){
        return rbacRoleService.findOne(id);
    }
    @PostMapping("/")
    public ResponseEntity addOne(@RequestBody RbacRole rbacRole){
        return rbacRoleService.addOne(rbacRole);
    }
    @DeleteMapping("/{id}")
    public ResponseEntity deleteOne(@PathVariable int id){
        return rbacRoleService.deleteOne(id);
    }
    @PutMapping("/")
    public ResponseEntity updateOne(@RequestBody RbacRole rbacRole){
        return rbacRoleService.updateOne(rbacRole);
    }
    @GetMapping("/{currentPage}/{pageSize}")
    public ResponseEntity search(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize, @RequestParam("key") String key, @RequestParam("key1") String key1) {
        return rbacRoleService.search(currentPage, pageSize, key, key1);
    }
}
